<?php
class hrd_spesifikasi_gaji_model extends MY_Model {
	var $nama_tabel = 'hrd_spesifikasi_gaji';
	
	function GetJSON($idKaryawan) {
		$ls_sql	= "	SELECT	a.*, b.nama_kode_bayar, b.ket_kode_bayar
					FROM	".$this->nama_tabel." a
					LEFT JOIN hrd_kode_bayar b ON a.id_kode_bayar_fk = b.id_kode_bayar_pk
					LEFT JOIN hrd_karyawan c ON a.id_karyawan_fk = c.id_karyawan_pk
					WHERE a.id_karyawan_fk = '".$idKaryawan."'
					ORDER BY ".(post('sort')=='' ? 'b.nama_kode_bayar' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order'));
					
		$list = $this->db->query($ls_sql)->result_array();
		$data = array('total' => count($list), 'rows' => $list);

		return json_encode( $data );					
	}

// aneh yang ini gak bisa
/*	
	function Add($arr_data){
		$this->db->insert($this->nama_tabel, $arr_data);
	}

	function Update($arr_data, $arr_rule){
		$this->db->update($this->nama_tabel, $arr_data, $arr_rule);
	}

	function DeleteSingle($arr_rule) {
		try {
			$this->db->delete($this->nama_tabel, array('id_spesifikasi_gaji_pk' => $arr_rule['id_spesifikasi_gaji_pk']));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}

	function GenerateId() {
		$sql = "select id_spesifikasi_gaji_pk
				from (
						select id_spesifikasi_gaji_pk
						from hrd_spesifikasi_gaji
						order by id_spesifikasi_gaji_pk desc
					)
				where ROWNUM <= 1
				";
		$data = $this->db->query($sql)->row_array();

		if (count($data) == 0) {
			return 1;
		} else {
			return $data['id_spesifikasi_gaji_pk']+1;
		}
	}
*/
}
?>